<template>
  <div>
    <div style="display: flex;align-items: center;justify-content: center;">
      <el-card style="width: 80%;margin-top: 30px">
        <div style="height: 50px;font-size: 25px">酒店日收入</div>
        <div style="margin-bottom: 10px">
          <el-input style="width: 200px;margin: 0 5px" placeholder="查询店名" v-model="hotel_name"></el-input>
          <el-button type="primary" @click="load(1)">查询</el-button>
          <el-button type="success" @click="reset">重置</el-button>
        </div>
        <el-table :data="income" stripe
                  :header-cell-style="{backgroundColor:'aliceblue',color:'#666'}" style="border-radius: 10px">
          <el-table-column prop="hotel_name" label="酒店名"></el-table-column>
          <el-table-column prop="day" label="日期"></el-table-column>
          <el-table-column prop="income" label="收入 "></el-table-column>
        </el-table>
        <div style="margin: 10px 0">
          <el-pagination
              @current-change="handleCurrentChange"
              :current-page="pageNum"
              :page-sizes="[100, 200, 300, 400]"
              :page-size="pageSize"
              layout="total,  prev, pager, next"
              :total="total">
          </el-pagination>
        </div>
      </el-card>
    </div>
  </div>
</template>

<script>
export default {
  name: "count",
  data() {
    return {
      dataToKeep: '',
      hotel: [],
      hotelData: {},
      income: [],
      pageNum: 1,
      pageSize: 5,
      total: 0,
      hotel_id: "",
      hotel_name: ""
    };
  },
  methods: {
    load() {
      this.$request.post('/daily_income_list/',
          {
            "hotel_id": this.hotel_id,
            "hotel_name": this.hotel_name,
            "page_id": this.pageNum,
            "page_size": this.pageSize,
          }).then(res => {
        if (res.code === '200') {
          this.income = res.data.income_list
          this.total = res.data.item_amount
          console.log(res.data)
        } else if (res.code === '501') {
        } else {
          this.$message.error(res.msg)
        }
      })
    },
    handleCurrentChange(pageNum) {
      this.load(pageNum)
    },
    reset() {
      this.hotel_name = ''
      this.load()
    },
  },
  created() {
    this.load()
  },
}
</script>


<style scoped>

</style>